package org.breezeiot.protodecode.enums;

/**
 * 0-15分钟<br>
 * 1-小时<br>
 * 2-日<br>
 * 3-月<br>
 * 4-周<br>
 * 5-旬<br>
 * 6-季
 * 
 * @author armording
 */
public enum PhaseTypeEnum {
                           PHASE_Z(0, "总"), PHASE_A(1, "A相"), PHASE_B(2, "B相"), PHASE_C(3, "C相");

    private final int    value;
    private final String name;

    PhaseTypeEnum(int value, String name) {
        this.value = value;
        this.name = name;
    }

    public int getValue() {
        return value;
    }

    public String getName() {
        return this.name;
    }

    public Short getShortValue() {
        return new Short((short) value);
    }

    /**
     * 通过传入的字符串匹配枚举，传入值
     * 
     * @param value
     * @return
     */
    public static PhaseTypeEnum getEnmuByValue(int value) {
        for (PhaseTypeEnum type : PhaseTypeEnum.values()) {
            if (value == type.getValue()) {
                return type;
            }
        }
        return null;
    }

    public static String getText(int value) {
        PhaseTypeEnum obj = getEnmuByValue(value);
        return obj == null ? null : obj.getName();
    }

}
